/***************************************************************************

-------------------
    begin                : 
    copyright            : kuzkok
    email                : kuzkok at gmail.com

***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*   
*   Данная программа является свободным программным обеспечением;         *
*   Вы можете распространять ее и/или модифицировать в соответствии с     *
*   GNU General Public License опубликованной Фондом свободного           *
*   программного обеспечения; используемая версия лицензии - 2 или        *
*   (по вашему выбору) любая более поздняя                                *
***************************************************************************/

#include "centerlinepolylineevent.h"

CenterlinePolylineEvent::CenterlinePolylineEvent(QString theTableName) :
    CenterlinePolyline(theTableName)
{    
}

CenterlinePolylineEvent::CenterlinePolylineEvent(QUuid theEventID, QString theTableName) :
        CenterlinePolyline(theEventID, theTableName)
{
    if(mObjectState)
    {
        mStationSeriesEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("stationserieseventid")).toString());
        mGroupEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("groupeventid")).toString());
        mBeginStation = mSelectQuery->value(mSelectQuery->record().indexOf("beginstation")).toDouble();
        mEndStation = mSelectQuery->value(mSelectQuery->record().indexOf("endstation")).toDouble();
        mCLValidityTolerance = mSelectQuery->value(mSelectQuery->record().indexOf("clvaliditytolerance")).toDouble();
        mCLValidityEditResponse = mSelectQuery->value(mSelectQuery->record().indexOf("clvalidityeditresponse")).toString();
    }
}

void CenterlinePolylineEvent::buildInsertStatement()
{
    CenterlinePolyline::buildInsertStatement();
    mInsertStatementFields += ", stationserieseventid"
                             ", groupeventid"
                             ", beginstation"
                             ", endstation"
                             ", clvaliditytolerance"
                             ", clvalidityeditresponse";
    mInsertStatementValues += ", :stationserieseventid"
                             ", :groupeventid"
                             ", :beginstation"
                             ", :endstation"
                             ", :clvaliditytolerance"
                             ", :clvalidityeditresponse";
}

void CenterlinePolylineEvent::buildUpdateStatement()
{
    CenterlinePolyline::buildUpdateStatement();
    mUpdateStatement += ",stationserieseventid = :stationserieseventid"
                       ",groupeventid = :groupeventid"
                       ",beginstation = :beginstation"
                       ",endstation = :endstation"
                       ",clvaliditytolerance = :clvaliditytolerance"
                       ",clvalidityeditresponse = :clvalidityeditresponse";
}

void CenterlinePolylineEvent::bindQueryValues(QSqlQuery &query)
{
    CenterlinePolyline::bindQueryValues(query);
    query.bindValue(":stationserieseventid", UuidToVariant(mStationSeriesEventID));
    query.bindValue(":groupeventid", UuidToVariant(mGroupEventID));
    query.bindValue(":beginstation", mBeginStation);
    query.bindValue(":endstation", mEndStation);
    query.bindValue(":clvaliditytolerance", mCLValidityTolerance);
    query.bindValue(":clvalidityeditresponse", mCLValidityEditResponse);
}
